<?php
class Dharmaksatria extends CI_Model {
	
	function get($table = null, $field = "*", $where = "1=1"){
		$this->db->select($field);
		$this->db->from($table);
		$this->db->where($where);
		$query = $this->db->get();
		return $query->result_array();
	}
	
	function add($table, $data){
		$this->db->insert($table, $data);
		return $this->db->insert_id();
	}
	
	function edit($w_param, $w_value, $table, $data){
		$this->db->where($w_param, $w_value);
		return $this->db->update($table, $data);
	}
	
	function delete($table, $param, $value){
		$this->db->delete($table, array($param => $value)); 
	}
	
	function login($username, $password) {
		$query = $this->db->get_where('user', array('username' => $username, 'password' => md5($password), 'level' => ADMIN_TYPE));
		return $query->row_array();
	}
	
}
?>
